package com.cwt.admin.manage;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckOr;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckRole;
import com.cwt.admin.common.BaseController;
import com.cwt.common.result.AjaxResult;
import com.cwt.service.service.SysMenuService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author chenwt
 * @version V1.0
 * @describe 【】
 * @date 2023年08月15日 15:28:32
 */
@Api(tags = "权限管理", value = "MenuController")
@RequestMapping("/menu")
@RestController
@SaCheckOr(
        login = @SaCheckLogin,
        role = @SaCheckRole("manage"),
        permission = @SaCheckPermission("system")
)
public class MenuController extends BaseController {

    @Autowired
    private SysMenuService sysMenuService;

    /**
     * 获取所有权限菜单
     * @return 权限菜单
     */
    @RequestMapping(value = "/allRoleMenu", method = {RequestMethod.POST, RequestMethod.GET})
    public @ResponseBody AjaxResult allRoleMenus() {
        return sysMenuService.allRoleMenus();
    }

    /**
     * 获取权限菜单
     * @param roleId 权限id
     * @return 权限菜单 id
     */
    @RequestMapping(value = "/roleMenus", method = {RequestMethod.POST, RequestMethod.GET})
    public @ResponseBody AjaxResult roleMenus(@RequestBody long roleId) {
        return sysMenuService.roleMenus(roleId);
    }

}
